package com.tanhua.dubbo.server.api;

import com.alibaba.dubbo.config.annotation.Service;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

@Service(version = "1.0.0")
public class CommentApiImpl implements CommentApi{

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public Integer queryCount(ObjectId publishId,Integer type) {

        Query query = Query.query(Criteria.where("publishId").is(publishId).and("commentType").is(type));
        long count = mongoTemplate.count(query, "quanzi_comment");

        return (int)count;
    }
}
